<template>
  <div
    v-if="pageData.afterEvent === 'showMessage'"
    class="t-center m15 success_text"
  >
    {{ pageData.showMessage || "提交成功" }}
  </div>
  <div v-if="pageData.isShare === 'Y'" class="social-share m15">
    <van-button block type="primary" @click="shareSurvey()">分享</van-button>
  </div>
  <div v-if="pageData.isReview === 'Y'" class="m15">
    <van-button :to="{ name: 'SurveyView' }" block plain type="primary">查看已填内容</van-button>
  </div>
  <div v-if="pageData.showLottery === 'Y'" class="lottery">
    <img :src="pageData.lotteryIconUrl" alt="" @click="jumpToLimit" />
  </div>
</template>
<script setup>
import { surveyStore } from "@/stores/survey.js";
import { jumpWeb, share } from "@/utils/common.js";
import { storeToRefs } from "pinia";


//defineOptions({ name: "SurveySuccess" });

const store = surveyStore();
const { surveyInfo } = storeToRefs(store);
const pageData = surveyInfo.value.pageData;
if (pageData.afterEvent === "towardPage") {
  jumpWeb(pageData.towardPage, "_self");
}
// 抽奖
const jumpToLimit = () => {
  jumpWeb(pageData.lotteryAddr);
};
// 分享 生成二维码
const shareSurvey = () => {
  share(
    location.origin +
    "/member/survey?token=#token#&type=h5&id=" +
    pageData.surveyId,
  );
};
</script>
<style lang="less" scoped>
.success_text {
  min-height: 10rem;
  display: flex;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  word-break: break-all;
}

.lottery {
  text-align: center;
  margin-top: 4rem;

  & img {
    max-width: 100%;
    cursor: pointer;
  }
}
</style>
